package com.netty.marshalling;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.ReferenceCountUtil;

/**
 * @author 顾志杰
 * @date 2021/3/4-9:07
 */
public class ClientHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        try {
            ResponseData rd = (ResponseData) msg;
            System.out.println("输出服务器响应内容: " + rd.getId());
        }finally {
            //释放资源防止资源撑爆
            ReferenceCountUtil.release(msg);
        }

    }
}
